/*
给定一个单向链表，将其翻转
输入：1->2->3->4->5 输出：5->4->3->2->1
*/
void chain::reverse(){
    /*
    node*dummyHead=new node();
    node*dummyTail=new node();
    node*ptr=head;
    dummyHead->next=head;
    while(ptr->next!=0)
        ptr=ptr->next;
    ptr->next=dummyTail;
    
    node*p1=dummyHead;
    node*p2=p1->next;
    node*p3=p2->next;
    while(p3!=0){
        p2->next=p1;
        p1=p2;
        p2=p3;
        p3=p3->next;
    }    
    head=p1;
    node*p=head;
    while(p->next!=dummyHead)
        p=p->next;
    p->next=0;
    delete dummyHead;
    delete dummyTail;
    */
    node*curNext;
    node*cur=head;
    node*pre=0;
    while(cur!=0){
        curNext=cur->next;
        cur->next=pre;
        pre=cur;
        cur=curNext;
    }
}